<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://unpkg.com/vue"></script>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css" />
  <style>
    * {
      margin: 0;
      padding: 0;
    }

    .container {
      position: absolute;
      width: 200px;
      height: 400px;
      background-color: pink;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
    }
  </style>
</head>

<body>
  <div id="root"></div>
  <script>
    /* 
      1. context
      - attrs NonProps属性
      - slots 插槽内容
      - emit 可用于触发事件，代替this.$emit()
      2. 没有定义template时，以setup返回值作为模板
      - 可以返回h函数的调用
    */

    const app = Vue.createApp({
      template: `
      <div class="container" >
        <child app="应用名">
          默认插槽
          </child>
      </div>
    `,
    })
    app.component('child', {
      // template: `
      // <div class="container" >
      //   子组件
      // </div>
      // `,
      setup(props, context) {
        const { h } = Vue
        const { attrs, slots, emit } = context
        console.log(attrs);
        console.log(slots.default());
        console.log(emit);
        return () => h('h3', {}, 'h函数调用')
      }
    })
    const vm = app.mount('#root');

  </script>
</body>

</html>